//            表单提交
function formSub(){
    var username = $("#username").val();
    var password = $("#password").val();
    var code = $("#code").val();
    var online=$("#online:checked").val();
    dataAjax(username, password, code,online);
}

//数据提交
function dataAjax(username, password, code,online) {
    $.ajax({
        // url: "/index.php?m=Admin&c=Index&a=checkLogin",
        url: "/index.php?m=Admin&c=Index&a=checkLogin",
        data: {
            username: username,
            password: password,
            code: code,
            online:online
        },
        type: "POST",
        error: function () {
            console.log("服务器繁忙");
        },
        success: function (data, status) {
            console.log(data);
            if (data.status =="1") {
                window.location.href = "/index.php?m=Admin&c=Index&a=index";
            }else{
                errormsg(data.sign);
            }


        }
    });
}
//表单验证
function formYz(){
    if(!$("#username").val()){
    layer.msg("请输入账号");
    return false;
    }
    if(!$("#password").val()){
         layer.msg("请输入密码");
        return false;
     }
     if($("#code").val()=='验证码:'){
       layer.msg("请输入验证码");
       return false;
     }
     formSub();
}
//提示错误信息
function errormsg(str) {
    layer.alert(str, {
        title: false
    }, function (index) {
        layer.close(index);
        window.location.reload(); //刷新当前页面.
    });
}